﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Data;
using Microsoft.SharePoint.Utilities;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using ICSharpCode.SharpZipLib.Zip;
using System.Collections;
using System.Xml;

/*
Developed By: Bhupender Bindra
Developed On: 16th Nov 2010
Description: The code provides the user to redirect the Download.aspx page and download the files in zip folder.   
*/
namespace DownloadContentKit.Download_Content
{
    public partial class Download_ContentUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SPSite site = SPContext.Current.Site;
                //this script used to pop up open in center and call the download aspx page
                string strScript = @"function openCenteredWindow(url) {
                       var width = 10;
                       var height = 10;
                       var left = parseInt((screen.availWidth/2) -100);
                       var top = parseInt((screen.availHeight/2) -100);
                       var windowFeatures = 'width=' + width + ',height=' + height + ',status,resizable,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top;
                       myWindow = window.open(url, 'subWind', windowFeatures);
                       }";
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "CallWindow", strScript, true);
                imbDownload.Attributes.Add("onClick", "javascript:openCenteredWindow('" + site.Url + "/_layouts/DownloadContent/Download.aspx')");
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
    }
}
